home *** CD-ROM | disk | FTP | other *** search
Wrap
/* DU_LIB v2 Gem Window Management & Dialog Library For Lattice C ©1994,95, by Craig Graham. Based on the DU_LIBv1 Library for HiSoft Basic. --->Library Header File */ #ifndef __DU_LIB__ #define __DU_LIB__ /*#include <dos.h>*/ #ifndef FMSIZE #define FNSIZE 40 /* maximum file node size */ #define FMSIZE 128 /* maximum file name size */ #define FESIZE 20 /* maximum file extension size */ #endif #ifndef __USE_GNU #include <aes.h> #include <vdi.h> #else #include <aesbind.h> #include <vdibind.h> #endif #include <xacc.h> // Xacc2 handler library (should be included now) #define max_windows 50 #define max_dialogs 100 #define ob_sizeof 24 /* Winx stuff */ #define WF_RETURN 1 #define WF_WINX 22360 #define WF_WINXCFG 22361 #define WF_OWNER 20 #define WF_BOTTOM 25 #define WM_BOTTOMED 33 /*DULIB custom messages*/ #define WM_CUSTOM_REDRAW 100 #ifndef WF_BEVENT #define WF_BEVENT 24 #define WM_UNTOPPED 30 #define WM_ONTOP 31 #define AP_TERM 50 #endif #ifndef DESK #define DESK 0 #endif /*ICFS & AES 5 stuff */ #ifndef WF_ICONIFY #define WF_ICONIFY 26 #define WF_UNICONIFY 27 #define WF_UNICONIFYXYWH 28 #define WM_ICONIFY 34 #define WM_UNICONIFY 35 #define WM_ALLICONIFY 36 #define SMALLER 0x4000 #endif /* keyboard focus policy */ #define FOCUS_MOUSE 1 #define FOCUS_FIELD 2 /* Drag'n'Drop */ #ifndef AP_DRAGDROP #define AP_DRAGDROP 63 #define DD_OK 0 #define DD_NAK 1 #define DD_EXT 2 #define DD_LEN 3 #define DD_TRASH 4 #define DD_PRINTER 5 #define DD_CLIPBOARD 6 #define DD_TIMEOUT 4000 /* timeout in milliseconds */ #define DD_NUMEXTS 8 #define DD_EXTSIZE 32L #define DD_NAMEMAX 128 /* max size of a drag&drop item name */ #define DD_HDRMAX (8+DD_NAMEMAX) /* max length of a drag&drop header */ #endif /*Colour Icon stuff*/ #ifndef G_CICON #define G_CICON 33 #endif /*Object flag masks*/ #define mask_none 0 #define mask_selectable 1 #define mask_default 2 #define mask_exit 4 #define mask_editable 8 #define mask_rbutton 16 #define mask_lastob 32 #define mask_touchexit 64 #define mask_hidetree 128 #define mask_indirect 256 #define mask_indicator 512 #define mask_activator 1024 /*Object state masks*/ #define mask_normal 0 #define mask_selected 1 #define mask_crossed 2 #define mask_checked 4 #define mask_disabled 8 #define mask_outlined 16 #define mask_shadowed 32 /*Scrollable List Widget constants*/ #define scroll_widget 0 #define scroll_drag_background 1 #define scroll_drag 2 #define scroll_text_area 3 #define scroll_up 4 #define scroll_down 5 /* Booleans */ #define TRUE 1 #define FALSE 0 /* DULIB Mode Control Setables */ typedef enum { DU_MODE_RIGHT_EQUALS_DOUBLE, DU_MODE_SCROLL_HIGHLIGHT_IS_INVERSE, DU_MODE_KEYPRESS_TO_WINDOW_UNDER_MOUSE } ModeType; typedef enum { wrm_scale, wrm_window, wrm_abs } Dmode; typedef enum{ DIAL_NO_CLOSE, DIAL_ROLLUP, DIAL_ROLLUP_BOTTOM_SCROLLER, DIAL_ROLLUP_SIDE_SCROLLER, DIAL_FIXED, DIAL_WIDGET_BAR } dialog_type; typedef enum { wt_null, wt_drawing, wt_static_menu, wt_alert, wt_menu_bar, wt_cro, wt_dialog, wt_dialog_side_bar, wt_dialog_bottom_bar, wt_iconified_drawing } Wtype; typedef short event; /* type for a callback function (pointer to a function) */ typedef short (*CallBack)(void); /*details of a scrolling text list*/ typedef struct { char *(*texts); /*list contents*/ short current; /*current highlighted option*/ short number; /*number of options in list*/ short display; /*number of lines to display*/ short start; /*base for currently displayed lines*/ } scroll_text; /* one line of text in a linked list of text lines */ typedef struct tl { char *the_text; /*array of chars containing the text*/ short eof_line; /*count of characters on this line==end of line*/ struct tl* prev; struct tl* next; } text_line; /* text widget structure */ typedef struct tp { short max_lines; /*maximum number of lines of text - 0 indicates unbounded */ short max_columns; /*maximum number of columns == length of the char array text in the text line struct*/ short cursor_y; /*row which has cursor on it (displayed lines)*/ short current_column; /*column which has the cursor on it*/ short display_lines_high; /*the number of lines of text which will physically fit into the widget on screen*/ text_line *current_line; /*pointer to line which has the cursor on it*/ text_line *text; /*list of the actual texts in the widget*/ text_line *display_baseline; /*pointer to first line to display in the widget*/ short sel_start_char; /* Selected text pointers */ short sel_end_char; text_line *sel_start_line; text_line *sel_end_line; } text_widget; /* Window Widget callback names */ #define WIDGET_CLOSE 1 #define WIDGET_FULL 2 #define WIDGET_ICONIFY 3 #define WIDGET_RESIZE 4 #define WIDGET_H_SLIDE 5 #define WIDGET_V_SLIDE 6 #define WIDGET_ARROW_UPPAGE 0|128 #define WIDGET_ARROW_DNPAGE 1|128 #define WIDGET_ARROW_UPLINE 2|128 #define WIDGET_ARROW_DNLINE 3|128 #define WIDGET_ARROW_LFPAGE 4|128 #define WIDGET_ARROW_RTPAGE 5|128 #define WIDGET_ARROW_LFLINE 6|128 #define WIDGET_ARROW_RTLINE 7|128 typedef struct { CallBack close_widget; CallBack full_widget; CallBack iconify_widget; CallBack resize_widget; CallBack h_slide; CallBack v_slide; CallBack arrows[8]; } window_widget_response; /* The main object extented info structure. This is a list objects in a given dialog, giving for each object: events,callbacks,keyhandler,redraw,popup-icon info,scroll widget & text widget info. Even if not all of these are use by a given object, it was easier to simply maintain them all for each object rather than have to keep seperate lists. */ typedef struct ml { struct ml* next; /*next in list*/ short object; /*object that this event is for*/ event this_event; /*event code (single click)*/ event this_devent; /*event code (double click)*/ CallBack callback; /*callback function for this object (single click)*/ CallBack dcallback; /*callback function for this object (double click)*/ CallBack Kcallback; /*callback funtion for this object (keypress) */ CallBack redraw; /*custom redraw function for this object*/ short popup_form; /*form for icon_popups containing other related icons*/ short popup_icon_current; /*current object number of icon to display*/ scroll_text stext; /*scrolling list details (if applicable)*/ text_widget wtext; /*text edit widget details (if applicable)*/ } Elist; /* structure containing details of a window */ typedef struct { Dmode redraw_mode; Wtype window_type; short the_dialog; } Wdetails; /* structure containing config info about a dialog */ typedef struct { short focus_mode; /*keyhandler focus mode for dialog - either FOCUS_MOUSE or FOCUS_FIELD*/ short current_focus; /*object that currently has keyboard focus in the dialog*/ char help_topic[30]; /*subject for hypertext help (if available) */ window_widget_response wind_widgets; /*handlers for the window widgets*/ } Ddetails; typedef enum { c_arrow,c_cross,c_circle,c_smiley,c_mover,c_arc,c_pointer } mouse_shape; extern short junk; extern short messB[40]; extern short timeB[40]; extern short AESid; /* Our AES id */ extern short AESversion; /* Current AES version */ extern short AESversion_m; /* Current AES version (minor revision number)*/ extern short x_handle; /* Automatically opened VDI workstation for us to work on */ extern Wdetails windows[max_windows]; extern Elist *event_value[max_dialogs]; extern Ddetails dialog_details[max_dialogs]; extern Elist *key_values; extern mouse_shape wm_mouse_shape; extern short wm_inv[512],wm_outv[200]; extern short menu; /*The menubar form number*/ extern short last_opened_window; /*The handle of the last handle opened by activate_dialog*/ extern short d_parm; /*Any parameter which has to be returned by a dialog (eg slider pos.)*/ extern short udx,udy,udw,udh,icon_x,icon_y; /* All callback globals */ extern short this_ob,this_dialog; /*The current object handle when any callback routine is called*/ /* Key triggered callbacks */ extern short kc_key; /* AES key code */ extern short kc_shstate; /* Keyboard shift state */ /*Redraw globals */ extern short cr_wind_handle; /*Custom redraw - window containing object */ extern GRECT cr_clip; /*Custom redraw object locations*/ extern GRECT cr_dclip; /*Custom redraw object display clip rectangle*/ extern short cr_mx,cr_my; /*Custom redraw/callback relative mouse location inside object*/ /*Specific to scroll texts */ extern short scroll_selection; /*index in text to string when a scroll text has been clicked on */ /* General information globals */ extern short scrn_x,scrn_y,scrn_w,scrn_h; /*screen - dimensions*/ extern short scrn_planes; /*screen - number of bitplanes*/ extern short wmi_total_buffering; extern CallBack XaccTextHandler; /*handler routine for Xacc2 text transfers*/ extern short click_count; /*number of mouse click events from last evnt_multi()*/ /* Configuration variables */ extern short RightClickEqualsDoubleClick; /*a right button click has same effect as a double click if this is set to TRUE*/ extern short ScrollSelectionIsInverse; /*selected item in a scrolling list is shown in inverse*/ extern short KeypressToWindowUnderMouse; /*control how the keyboard handler behaves */ /*Clipboard stuff*/ extern char clipboard_path[FMSIZE+10]; /*path to the GEM clipboard*/ /*Timer called routine stuff*/ extern short timer_rate; extern CallBack timer_callback; /* ============================= The DU_LIB Library Routines ============================= */ /*DULIB.C*/ short enviroment_initialise(void); /* setup the system prior to use */ short close_down(); /* Shutdown a program, closing all windows and removing the menu bar */ short install_menu(short m); /* Install a GEM menu bar at the top of the screen */ event WaitEvent(void); /* The Main event loop */ event PollEvent(short t_poll); /* Poll for events */ /*PROC_MSG.C*/ event process_message(short mb[]); /* Process a GEM message */ short redraw_window(short wind_handle); short custom_redraw_window(short wind_handle); void Set_dialog_widget_callback(short dialog, short widget, CallBack c); /*EVENTS.C*/ event Get_object_event(short dialog, short ob); /*Get an event code for an object in a dialog (single click)*/ short Set_object_event(short dialog, short ob, event e); /* Set an event code for an object (single click)*/ event Get_object_devent(short dialog, short ob); /*Get an event code for an object in a dialog (double click)*/ short Set_object_devent(short dialog, short ob, event e); /* Set an event code for an object (double click)*/ CallBack Get_object_callback(short dialog, short ob); /* Get the address of a callback routine for an object (single click)*/ short Set_object_callback(short dialog, short ob, CallBack c); /* Set the address of a callback routine for an object (single click)*/ CallBack Get_object_dcallback(short dialog, short ob); /* Get the address of a callback routine for an object (double click)*/ short Set_object_dcallback(short dialog, short ob, CallBack c); /* Set the address of a callback routine for an object (double click)*/ CallBack Get_dialog_Kcallback(short dialog); /*Get addr of a dialog general key handler */ short Set_dialog_Kcallback(short dialog, CallBack c); /*Set addr of a dialog general key handler */ CallBack Get_object_Kcallback(short dialog, short ob); /*Get addr of a specific object key handler */ short Set_object_Kcallback(short dialog, short ob, CallBack c); /*Set addr of a specific object key handler */ CallBack Get_key_callback(short key); /*Get a specific key callback */ short Set_key_callback(short key, CallBack c); /*Set a specific key callback */ CallBack Get_object_redraw(short dialog, short ob); short Set_object_redraw(short dialog, short ob, CallBack c); short find_event(short dialog,short ob, Elist *ee[1]); /* Find an object's callback/event entry */ Elist* new_event_struct(short dialog, short ob); /* Create & initialise a new event structure for an object in a dialog */ /*WINDIAL.C*/ short set_window_title(short h, char *a); /* Set the title of a window */ short activate_dialog(short dialog, char *n, dialog_type t);/* Activate a windowed dialog */ short display_dial(short wind_handle); /* Display the dialog associated with window wind_handle */ short custom_display_dial(short wind_handle); /* Display only the custom redraw objects associated with a window */ short wind_display_object(short wind_handle, short object); int intersection(short x1,short y1,short w1,short h1,short x2,short y2,short w2,short h2,short *x,short *y,short *w,short *h); short close_dialog(short dialog); /* Close all copies of a dialog */ short close_dialog_window(short e_wind); /* Close a dialog window */ short dialog_update(short d); /* Update a dialog using AES redraw messages (if it is open)*/ short dialog_display(short d); /* Redraw a dialog immediately (if it is open)*/ short dialog_object_display(short d, short o); short process_win_dial(short wh,short x,short y); short Radio_b(OBJECT *t, short object); short GetParent(OBJECT *t,short object); short Get_ob_info(OBJECT *dialog,short ob,short *otype,short *oflags,short *ostate); short set_dialog_text(short dialog, short object, char* t); /* Sets a text object in a dialog to a given string*/ int redraw_custom(short wind_handle); short custom_display_object(short wind_handle, short ob); /* Display only a specified custom redraw object associated with a window */ /*MESSAGES.C*/ int update_window(short wind_handle); /* Update a window by sending ourselves a wm_redraw message via GEM.*/ int custom_update_window(short wind_handle); /* Update a window by sending a WM_CUSTOM_REDRAW message to only redraw custom objects */ int send_redraw(short sx, short sy,short sw,short sh); /* Send redraw messages to all our windows for the area (sx,sy,sw,sh)*/ int I_send_message(short wind_handle, short msg); /* Send ourselves a control message via GEM.*/ short Set_XaccTextHandler(CallBack c); /* Set a callback routine to handle any Xacc2 ACC_TEXT messages */ /*POPUP.C*/ short form_popup(short dialog,short object, short n, short current, char* t[1]); /*Form an <n> entry pop-up menu for <object> in <dialog>, and return a selection from it.*/ /*S_LIST.C*/ short Set_scroll_list(short dialog, short ob, short event, char *text_list[], short nt, short nd); short Change_scroll_list(short dialog, short ob, char *text_list[], short nt); short SelectFromScrollList(void); short DisplayScrollList(void); short Get_object_scroll(short dialog, short object, char *(*t[]), short *start, short *nt, short *nd, short *current); short ScrollListDrag(void); short ScrollListDown(void); short ScrollListUp(void); /*IPOPUP.C*/ void Set_icon_popup(short dialog, short object, short p_form); short Get_icon_popup(short dialog, short object); short do_icon_popup(void); short display_p_icon(void); /*MODE.C*/ void DU_mode(ModeType mt, short m); /*TEXTEDIT.C*/ void Set_text_widget(short dialog, short ob, short max_columns, short max_lines); void Change_widget_text(short dialog, short ob, char *t[], short lines); short Get_widget_text(short dialog, short ob, char ***text, short text_lines); short TW_display(void); short TW_keypress(void); short TW_mouse_click(void); /*STDKEY.C*/ void Set_standard_keyboard(void); short std_key_close_window(void); short std_key_cycle_window(void); /*ED_TEXT.C*/ void Set_object_editable(short dialog,short object); void Set_dialog_Kfocus_policy(short dialog, short focus_policy); void Set_dialog_Kfocus(short dialog, short object); short ted_callback(void); short ted_display_cursor(void); short ted_mouseclick(void); /*TIMER.C*/ void Set_timer_callback(short t, CallBack c); /*STG_HELP.S*/ void Set_application_helpfile(char *h); void Set_dialog_help_topic(short dialog, char *h); short dialog_help(void); /*============= RESOURCE.C ==============*/ void rsrc_form2mono(short d,short b); /* Convert a colour form into a mono one */ void *LoadResources(char *fname,short designWidth,short designHeight); void FreeResources(void *base); OBJECT *ResourceTree(void *base,short num); char *ResourceString(void *base,short num); void *ResourceImage(void *base,short num); int DUrsrc_load(char *n); int DUrsrc_free(void); int DUrsrc_gaddr(int type, int index, void *addr); /* Simulate the standard GEM AES resource access functions using Steve Sowerby's resource routines. */ #undef rsrc_load #undef rsrc_free #undef rsrc_gaddr #define rsrc_load DUrsrc_load #define rsrc_free DUrsrc_free #define rsrc_gaddr DUrsrc_gaddr /* I only ever use the R_TREE mode of rsrc_gaddr, so I define this to get a bit of extra speed - undefine this symbol if you want to use R_STRING & R_IMAGEDATA as well */ #define RSRC_GADDR_ONLY_TREES #ifdef _DULIB_FOR_MINT /*MINTPAT.C*/ void _XCEXIT(void); /*COOKIE.S*/ int getcookie(long,long *); #endif #endif